public class p1017_360ms {

	static//
	// -----
	// -----
	public class Main {
		public static void main(String[] args) throws Exception {
			java.util.Scanner in = new java.util.Scanner(System.in);
			while (true) {
				int sum = 0, nums[] = new int[6];
				for (int i = 0; i < 6; i++) {
					int num = in.nextInt();
					nums[i] = num;
					sum += num;
				}
				if (sum <= 0)
					break;

				System.out.println(process(nums));
			}
		}

		static int process(int[] nums) {
			// 6x6
			int sum = nums[5];
			int space = 0;
			// 5x5: (5) + (1)x11
			sum += nums[4];
			space += nums[4] * 11;
			// 4x4: (4) + (2)x5
			sum += nums[3];
			int minus2 = Math.min(nums[3] * 5, nums[1]);
			nums[1] -= minus2;
			space += (nums[3] * 5 - minus2) * 4;
			// 3x3: (3)x4 | (3)x3 + (2) | (3)x2 + (2)x3 | (3)x1 + (2)x5
			sum += nums[2] / 4;
			int left3 = nums[2] % 4;
			if (left3 > 0) {
				sum++;
				minus2 = Math.min(7 - 2 * left3, nums[1]);
				nums[1] -= minus2;
				space += (4 - left3) * 9 - minus2 * 4;
			}
			// 2x2
			sum += nums[1] / 9;
			int left2 = nums[1] % 9;
			if (left2 > 0) {
				sum++;
				space += (9 - left2) * 4;
			}
			// 1x1
			if (nums[0] > space)
				sum += (nums[0] - space + 35) / 36;
			return sum;
		}
	}

	// -----
	// -----

	public static void main(String[] args) throws Exception {
		Judge.run();
	}

}
